<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>

	<body>
		<div id="app">
			<cpn2></cpn2>
			<br />
			<cpn1></cpn1>
		</div>

		<script src="../lib/vue.js"></script>
		<script>
			// 1.创建子组件构造器对象
			const cpnC1 = Vue.extend({
				template: `
						<div>
			       <h2>我是标题1</h2>
			       <p>我是内容，哈哈哈</p>
						 </div>
						 `
			});
			// 1.创建父组件构造器对象
			const cpnC2 = Vue.extend({
				template: `
						<div>
			       <h2>我是标题2</h2>
						 <p>我是内容，呵呵呵</p>
						 <cpn1></cpn1>
						 </div>
						 `,
				components: {
					//注册子组件
					cpn1: cpnC1
				}
			});
			//root根组件
			let vm = new Vue({
				el: "#app",
				data: { message: "hello" },
				components: {
					//注册父组件
					cpn2: cpnC2,
					cpn1: cpnC1
				},
				methods: {}
			});
		</script>
	</body>
</html>
